<template>
  <el-card class="link-main" shadow="never">
    <div class="link-main-part">
      <h3 class="link-main-title">
        <i class="el-icon-third-link iconfont-link" />
        <span>友情链接</span>
      </h3>
      <p class="link-main-subtitle">相识也是缘分</p>
      <ul class="link-main-list">
        <li
          v-for="item in 10"
          :key="item"
          class="link-item"
          data-title="兴趣指引方向，会玩才会学"
        >
          <a href="#">
            <el-image src="/article.png" fit="cover" class="link-item-bgi" />
            <div class="link-main-info">
              <el-avatar
                src="/article.png"
                fit="cover"
                :size="66"
                class="link-item-avatar"
              />
              <p class="link-item-name ellipsis1">Colorful</p>
            </div>
          </a>
        </li>
      </ul>
    </div>
    <DividerHr class="clearfix" />
    <div class="link-main-apply">
      <h3 class="link-main-apply-title">
        <i class="el-icon-third-link iconfont-link" />
        <span>友链申请</span>
      </h3>
      <div class="link-main-require">
        <p class="link-main-require-title">友链要求:</p>
        <ul class="link-main-require-content">
          <li>博客网站</li>
          <li>网站链接为域名，而非 ip or ip: 端口</li>
          <li>网站定期更新</li>
        </ul>
      </div>
      <div class="link-main-cur">
        <p class="link-main-cur-title">本站友链:</p>
        <ul class="link-main-cur-content">
          <li>Blog 名字：Colorful</li>
          <li>Blog 地址：https://www.xxx.com</li>
          <li>Blog 头像：https://www.xxx.com/img/avatar.png</li>
          <li>Blog 简介：Colorful Blog</li>
        </ul>
      </div>
    </div>
    <DividerHr />
    <div class="message-container">
      <p class="message-header">
        <i class="el-icon-third-liuyanban is-vertical" />
        <span>留言</span>
      </p>
      <Markdown />
      <div class="message-footer">
        <p class="no-message" v-if="messages.length <= 0">快来留言吧~</p>
        <div v-else>
          <p class="message-total">
            <span>{{ messages.length }}</span>
            条留言
          </p>
          <ul class="message-list">
            <li v-for="item of messages" :key="item.messageId">
              <CommentItem :message="item" />
            </li>
          </ul>
        </div>
      </div>
    </div>
  </el-card>
</template>

<script>
import $api from "$api/messages";
import DividerHr from "$components/DividerHr";
import Markdown from "$components/editor/Markdown";
import CommentItem from "$components/CommentItem";
export default {
  name: "LinkMain",
  components: {
    DividerHr,
    Markdown,
    CommentItem,
  },
  data() {
    return {
      messages: [],
    };
  },
  mounted() {
    this.getMessages();
  },
  methods: {
    getMessages() {
      $api.getMessages().then((res) => {
        if (res.status === 200) {
          this.messages = res.data;
        }
      });
    },
  },
};
</script>

<style lang="stylus" scoped>
h3 {
  font-size: 0.2rem;
}

h3 i[class*="el-icon-third-"] {
  font-weight: bold;
  margin-right: 0.05rem;
}

.link-main-subtitle {
  color: var(--fontLevel2);
  font-size: 0.15rem;
  font-style: italic;
  margin: 0.2rem 0;
}

.link-main-list {
  display: flex;
  flex-wrap: wrap;
}

.link-item {
  width: calc(25% - 0.15rem);
  height: 1.3rem;
  margin: 0.15rem 0.07rem;
  border-radius: 0.1rem;
  overflow: hidden;
  position: relative;
  transition: all 0.3s ease 0s, transform 0.6s cubic-bezier(0.6, 0.2, 0.1, 1) 0s;
  box-shadow: 0 0.14rem 0.38rem rgba(0, 0, 0, 0.08), 0 0.03rem 0.08rem rgba(0, 0, 0, 0.06);
}

.link-item:hover:before {
  width: inherit;
  color: #fff;
  font-size: 0.2rem;
  text-align: center;
  border-radius: 0.1rem;
  padding: 0.1rem;
  margin: auto;
  position: fixed;
  top: 10%;
  left: 0;
  right: 0;
  z-index: 100;
  content: attr(data-title);
  background-color: rgba(254, 95, 85, 0.8);
}

.link-item a {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
}

.link-item:hover .link-main-info {
  transform: translateY(-100%);
}

.link-item:hover .link-item-bgi {
  transform: scale(1.1);
}

.link-item-bgi {
  width: 100%;
  height: 100%;
  transition: all 1s;
}

.link-main-info {
  width: 100%;
  height: 100%;
  text-align: center;
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
  background-color: rgba(255, 255, 255, 0.7);
  transition: transform 0.5s cubic-bezier(0.6, 0.2, 0.1, 1) 0s;
}

.link-item-avatar {
  height: 100%;
  position: relative;
  top: 0.12rem;
  z-index: 1;
  box-shadow: 0 0 0.1rem rgba(0, 0, 0, 0.3);
}

.link-item-name {
  width: 100%;
  color: var(--fontLevel1);
  font-size: 0.16rem;
  padding: 0.23rem 10% 0.25rem;
  position: relative;
  top: -20px;
  box-shadow: 0 0 0.1rem rgba(0, 0, 0, 0.3);
  background-color: rgba(255, 255, 255, 0.7);
}

.link-main-apply ul {
  margin-left: 0.15rem;
}

.link-main-apply ul li:before {
  content: '';
  width: 0.06rem;
  height: 0.06rem;
  vertical-align: middle;
  display: inline-block;
  border-radius: 50%;
  border: 0.03rem solid var(--colorLevel1);
  margin-right: 0.1rem;
}

.link-main-require, .link-main-cur {
  font-size: 0.14rem;
  border-left: 0.05rem solid #428bca;
  border-radius: 0.03rem;
  padding: 0.15rem;
  margin: 0.2rem 0;
  background: #eef7fa;
}

.message-header {
  display: flex;
  padding-bottom: 0.1rem;
}

.message-header span {
  color: var(--fontLevel1);
  font-size: 0.2rem;
  font-weight: bold;
}

.message-header i[class*="el-icon-third-"] {
  color: var(--fontLevel1);
  font-size: 0.3rem;
  margin-right: 0.05rem;
}

.no-message {
  color: #555;
  text-align: center;
  padding: 0.2rem 0;
}

.message-total {
  font-size: 0.25rem;
  font-weight: bold;
  padding: 0.2rem 0;
}
</style>